Skip to content

misc: cleanup requires inside checks - v1#2938

Closed
jasonish wants to merge 3 commits intoOISF:masterfrom
jasonish:requires-fixups/v1
Closed

misc: cleanup requires inside checks - v1#2938
jasonish wants to merge 3 commits intoOISF:masterfrom
jasonish:requires-fixups/v1

Conversation

@jasonish
Copy link
Member

Filters that prevent a check from running should be inside a requires block as
this is what is documented in the README.

  • Fix-up tests that didn't have their require expressions inside "requires"
  • Fail on unknown keywords in a check block
  • Remove now unused code

- Move require expressions in shell check to requires object
- Error if an unknown key is provided in a shell check
- Move require expressions in filter check to requires object
- Error if an unknown key is provided in a filter check
@jasonish
Copy link
Member Author

jasonish commented Feb 28, 2026

gt-version: 8.0.4
requires:
lt-version: 8.0.4
gt-version: 8.0.4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an impossible condition, however not new with this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @jufajardini did this for check to run on 7 and on main, but not on 8

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise check_filter_test_version_compat should be updated to catch more impossible cases

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspiring : #2944

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, but now the code did not check the gt-version at the root because it missed

@@ -551,12 +554,15 @@ class FilterCheck:
         req_version = self.config.get("version")
         min_version = self.config.get("min-version")
         lt_version = self.config.get("lt-version")
+        gt_version = self.config.get("gt-version")
         if req_version is not None:
             requires["version"] = req_version
         if min_version is not None:
             requires["min-version"] = min_version
         if lt_version is not None:
             requires["lt-version"] = lt_version
+        if gt_version is not None:
+            requires["gt-version"] = gt_version
         check_filter_test_version_compat(requires, self.test_version)
         feature = self.config.get("feature")
         if feature is not None:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, but now the code did not check the gt-version at the root because it missed

@@ -551,12 +554,15 @@ class FilterCheck:
         req_version = self.config.get("version")
         min_version = self.config.get("min-version")
         lt_version = self.config.get("lt-version")
+        gt_version = self.config.get("gt-version")
         if req_version is not None:
             requires["version"] = req_version
         if min_version is not None:
             requires["min-version"] = min_version
         if lt_version is not None:
             requires["lt-version"] = lt_version
+        if gt_version is not None:
+            requires["gt-version"] = gt_version
         check_filter_test_version_compat(requires, self.test_version)
         feature = self.config.get("feature")
         if feature is not None:

Does this PR need a fix?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your PR is good and I see further improvements

@catenacyber catenacyber added the framework Has a suricata-verify framework change label Mar 2, 2026
Copy link
Collaborator

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this

We should even further and add some code like

diff --git a/run.py b/run.py
index ad8f3057..ffb11d51 100755
--- a/run.py
+++ b/run.py
@@ -339,6 +339,9 @@ def check_requires(requires, suricata_config: SuricataConfig, test_dir=None):
                 raise UnsatisfiedRequirementError(
                         "requires at least version {}".format(min_version))
         elif key == "lt-version":
+            if "gt-version" in requires:
+                raise UnnecessaryRequirementError(
+                        "test has both lt-version {} and gt-version {}".format(requires["lt-version"], requires["gt-version"]))
             lt_version = requires["lt-version"]
             if not is_version_compatible(version=lt_version,
                     suri_version=suri_version, expr="lt"):

@catenacyber catenacyber added the tests pass These new tests should pass label Mar 2, 2026
@jasonish
Copy link
Member Author

jasonish commented Mar 2, 2026

I love this

We should even further and add some code like

diff --git a/run.py b/run.py
index ad8f3057..ffb11d51 100755
--- a/run.py
+++ b/run.py
@@ -339,6 +339,9 @@ def check_requires(requires, suricata_config: SuricataConfig, test_dir=None):
                 raise UnsatisfiedRequirementError(
                         "requires at least version {}".format(min_version))
         elif key == "lt-version":
+            if "gt-version" in requires:
+                raise UnnecessaryRequirementError(
+                        "test has both lt-version {} and gt-version {}".format(requires["lt-version"], requires["gt-version"]))
             lt_version = requires["lt-version"]
             if not is_version_compatible(version=lt_version,
                     suri_version=suri_version, expr="lt"):

Follwup pr perhaps. Seems to be a separate concern.

@victorjulien
Copy link
Member

Merged in #2949, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework Has a suricata-verify framework change tests pass These new tests should pass

Development

Successfully merging this pull request may close these issues.

3 participants